const Router = require('koa-router'); 
const router = new Router({prefix:'/topics'});
const { find, checkTopicExist ,findById, create, update, listTopicFollower, listQuestions} = require("../controllers/topics");
//自己编写的中间件
// const jsonwebtoken = require('jsonwebtoken');
const jwt = require('koa-jwt');
const { secret } = require('../config');

//使用插件
const auth = jwt({ secret })
router.get('/',find)
router.get('/:id',checkTopicExist,findById)
router.post('/', auth, create)
router.patch('/modify/:id',checkTopicExist,update)
//获取某个话题的粉丝
router.get('/:id/followers',checkTopicExist,listTopicFollower)
//获取问题列表
router.get('/:id/questions',checkTopicExist,listQuestions)

module.exports = router;